<?php

namespace App\Http\Controllers\staff;

use Illuminate\Http\Request;
use DB;
use Cookie;
use Hash;
use App\Http\Controllers\Controller;
//模型
use App\Models\Role;

class ServiceController extends Controller
{
    public function getIndex(Request $request)
    {
        //获取工单信息
        $staffInfo = $request->cookie('staffInfo');
        $areaArr = DB::table('area_staff as as')
            ->leftJoin('area as a', 'a.id', '=', 'as.area_id')
            ->select('area_id')
            ->where('staff_id', $staffInfo['id'])
            ->get();
        //查询管理范围内合同信息
        $data = DB::table('room as r')
            -> leftJoin('area as a','a.id','=','r.area_id')
            -> leftJoin('contract as c','c.room_id','=','r.id')
            -> select('c.*','r.name as rname','a.name as aname')
            -> whereIn('r.area_id',$areaArr)
            -> get();
        return view('staff.service.index',['data'=>$data]);
    }
}